<?php

namespace App\Package\Code;

use Illuminate\Support\Str;

/**
 * 编码生成器
 *
 * Date: 10/04/2018
 * @author George
 * @package App\Package\Code
 */
class Code
{
	/**
	 * 生成随机编码
	 *
	 * Date: 10/04/2018
	 * @author George
	 * @param int $length
	 * @param bool $number
	 * @return int|string
	 */
	static public function generator(int $length = 6, bool $number = true)
	{
		if ($number) {
			return rand(pow(10, ($length - 1)), pow(10, $length) - 1);
		}
		return Str::random($length);
	}
}
